feat: implement endpoint for createTopic method#2215
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Up to standards ✅🟢 Issues
|
…CK handlers Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
582ac6e to
376553e
Compare
…CK handlers Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
7fd7283 to
86e567c
Compare
…CK handlers Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 48aea2b7-e248-4042-b628-0f2bae8d7d0f
📒 Files selected for processing (8)
tck/handlers/__init__.pytck/handlers/key.pytck/handlers/topic.pytck/param/common.pytck/param/topic.pytck/response/topic.pytck/util/param_utils.pytests/tck/topic_handlers_test.py
This comment was marked as resolved.
This comment was marked as resolved.
aceppaluni
left a comment
There was a problem hiding this comment.
Happy to review when changes are addressed.
…CK handlers Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (3)
tck/param/topic.py (2)
23-28:⚠️ Potential issue | 🟠 Major | ⚡ Quick winReject malformed
fixedFee.amountduring parsing.When
amountis a non-numeric value (e.g.,"bad"),to_int()returnsNoneinstead of raising an error. This allows invalid input to pass parameter validation and fail later during transaction construction, producing an internal error instead of a properinvalid paramsresponse at the JSON-RPC boundary.🛡️ Proposed fix
`@classmethod` def parse_json_params(cls, params: dict) -> CreateTopicFixedFeeParams: + amount = to_int(params.get("amount")) + if amount is None: + raise ValueError("fixedFee.amount must be an integer") return cls( - amount=to_int(params.get("amount")), + amount=amount, denominatingTokenId=non_empty_string_or_none(params.get("denominatingTokenId")), )
39-51:⚠️ Potential issue | 🟠 Major | ⚡ Quick winValidate
fixedFeestructure when present.If the caller provides
{"fixedFee": "bad"}(a non-dict value), line 50'sisinstancecheck fails and the method silently assignsNoneinstead of raising a validation error. This masks malformed input that should be rejected at the parameter boundary.🛡️ Proposed fix
`@classmethod` def parse_json_params(cls, params: dict) -> CreateTopicCustomFeeParams: fixed_fee = params.get("fixedFee") + if fixed_fee is not None and not isinstance(fixed_fee, dict): + raise ValueError("fixedFee must be an object") fee_collector_account_id = params.get("feeCollectorAccountId") if isinstance(fee_collector_account_id, str): fee_collector_account_id = fee_collector_account_id.strip() return cls( feeCollectorAccountId=fee_collector_account_id, feeCollectorsExempt=to_bool(params.get("feeCollectorsExempt")), fixedFee=(CreateTopicFixedFeeParams.parse_json_params(fixed_fee) if isinstance(fixed_fee, dict) else None), )tck/handlers/topic.py (1)
70-82:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFail fast when the session does not resolve to a client.
get_client()at line 72 can returnNone, but lines 80 and 82 useclientwithout validation. An unrecognizedsessionIdwill surface as an internal error (likelyAttributeErroror SDK exception) instead of a deterministic JSON-RPC error.🛡️ Proposed fix
`@rpc_method`("createTopic") def create_topic(params: CreateTopicParams) -> CreateTopicResponse: client = get_client(params.sessionId) + if client is None: + raise ValueError("Unknown session ID") transaction = _build_create_topic_transaction(params)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: cbbd17ed-a99b-4cd4-9659-c3e2d13cf95a
📒 Files selected for processing (2)
tck/handlers/topic.pytck/param/topic.py
AntonioCeppellini
left a comment
There was a problem hiding this comment.
Hi @MonaaEid great work so far :D
i agree with the 3 coderabbit suggestions.
are there any tests incoming for this PR?
aceppaluni
left a comment
There was a problem hiding this comment.
I agree with code rabbit. Please let us know if you have questions on the suggestions
Additionally, did you commit test files?
|
Nope, there are no test files in unit/integration tests if you mean that @AntonioCeppellini @aceppaluni |
|
@MonaaEid, Please update the branch |
integration tests not relevant in this case
|
👋 Hi @MonaaEid! Great work completing a Advanced issue! 🎉 Thanks for your contribution! 🚀 Here are some issues you might want to explore next: 🌟 Stay connected: Happy coding! 🚀 |
Description:
This pull request introduces a new "create topic" feature, along with improvements and refactoring to the key handling. The most significant changes are the addition of topic creation support with custom fee parameters, enhancements to key generation formatting and error handling.
New Topic Creation Feature:
tck/handlers/topic.pyimplementing thecreateTopicRPC method, supporting topic creation with custom fees, admin/submit keys, auto-renew account handling, and error mapping for various account states.tck/param/topic.py(CreateTopicParams,CreateTopicCustomFeeParams,CreateTopicFixedFeeParams) to parse and validate topic creation parameters, including support for custom fees and key lists.CreateTopicResponseintck/response/topic.pyfor standardized topic creation responses.Key Handling Improvements:
tck/handlers/key.pyto use a helper for canonical public key formatting, improved error messages, and standardized recursive key processing and handler signatures for clarity and maintainability.Related issue(s):
Fixes #2207
Notes for reviewer:

64 tests passed
Checklist